package org.jivesoftware.smack.packet;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public class Privacy extends IQ
{
  private boolean declineActiveList = false;
  private String activeName;
  private boolean declineDefaultList = false;
  private String defaultName;
  private Map<String, List<PrivacyItem>> itemLists = new HashMap();

  public List<PrivacyItem> setPrivacyList(String paramString, List<PrivacyItem> paramList)
  {
    getItemLists().put(paramString, paramList);
    return paramList;
  }

  public List<PrivacyItem> setActivePrivacyList()
  {
    setActiveName(getDefaultName());
    return (List)getItemLists().get(getActiveName());
  }

  public void deletePrivacyList(String paramString)
  {
    getItemLists().remove(paramString);
    if ((getDefaultName() != null) && (paramString.equals(getDefaultName())))
      setDefaultName(null);
  }

  public List<PrivacyItem> getActivePrivacyList()
  {
    if (getActiveName() == null)
      return null;
    return (List)getItemLists().get(getActiveName());
  }

  public List<PrivacyItem> getDefaultPrivacyList()
  {
    if (getDefaultName() == null)
      return null;
    return (List)getItemLists().get(getDefaultName());
  }

  public List<PrivacyItem> getPrivacyList(String paramString)
  {
    return (List)getItemLists().get(paramString);
  }

  public PrivacyItem getItem(String paramString, int paramInt)
  {
    Iterator localIterator = getPrivacyList(paramString).iterator();
    Object localObject = null;
    while ((localObject == null) && (localIterator.hasNext()))
    {
      PrivacyItem localPrivacyItem = (PrivacyItem)localIterator.next();
      if (localPrivacyItem.getOrder() == paramInt)
        localObject = localPrivacyItem;
    }
    return localObject;
  }

  public boolean changeDefaultList(String paramString)
  {
    if (getItemLists().containsKey(paramString))
    {
      setDefaultName(paramString);
      return true;
    }
    return false;
  }

  public void deleteList(String paramString)
  {
    getItemLists().remove(paramString);
  }

  public String getActiveName()
  {
    return this.activeName;
  }

  public void setActiveName(String paramString)
  {
    this.activeName = paramString;
  }

  public String getDefaultName()
  {
    return this.defaultName;
  }

  public void setDefaultName(String paramString)
  {
    this.defaultName = paramString;
  }

  public Map<String, List<PrivacyItem>> getItemLists()
  {
    return this.itemLists;
  }

  public boolean isDeclineActiveList()
  {
    return this.declineActiveList;
  }

  public void setDeclineActiveList(boolean paramBoolean)
  {
    this.declineActiveList = paramBoolean;
  }

  public boolean isDeclineDefaultList()
  {
    return this.declineDefaultList;
  }

  public void setDeclineDefaultList(boolean paramBoolean)
  {
    this.declineDefaultList = paramBoolean;
  }

  public Set<String> getPrivacyListNames()
  {
    return this.itemLists.keySet();
  }

  public String getChildElementXML()
  {
    StringBuilder localStringBuilder = new StringBuilder();
    localStringBuilder.append("<query xmlns=\"jabber:iq:privacy\">");
    if (isDeclineActiveList())
      localStringBuilder.append("<active/>");
    else if (getActiveName() != null)
      localStringBuilder.append("<active name=\"").append(getActiveName()).append("\"/>");
    if (isDeclineDefaultList())
      localStringBuilder.append("<default/>");
    else if (getDefaultName() != null)
      localStringBuilder.append("<default name=\"").append(getDefaultName()).append("\"/>");
    Iterator localIterator1 = getItemLists().entrySet().iterator();
    while (localIterator1.hasNext())
    {
      Map.Entry localEntry = (Map.Entry)localIterator1.next();
      String str = (String)localEntry.getKey();
      List localList = (List)localEntry.getValue();
      if (localList.isEmpty())
        localStringBuilder.append("<list name=\"").append(str).append("\"/>");
      else
        localStringBuilder.append("<list name=\"").append(str).append("\">");
      Iterator localIterator2 = localList.iterator();
      while (localIterator2.hasNext())
      {
        PrivacyItem localPrivacyItem = (PrivacyItem)localIterator2.next();
        localStringBuilder.append(localPrivacyItem.toXML());
      }
      if (!localList.isEmpty())
        localStringBuilder.append("</list>");
    }
    localStringBuilder.append(getExtensionsXML());
    localStringBuilder.append("</query>");
    return localStringBuilder.toString();
  }
}

/* Location:           D:\hygieia\userclient\common\libs\easemobchat_2.1.8.jar
 * Qualified Name:     org.jivesoftware.smack.packet.Privacy
 * JD-Core Version:    0.6.1
 */